package com.j.lemon.learn.basic.file;

import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;

/**
 * @Author lijunjun
 * @Date 2019-03-14 18:08
 * @Description
 */
public class FIlesTest {

    @Test
    void Files() throws IOException {
        Path path = Paths.get("/Users", "lijunjun", "work", "file.log");
        byte[] bytes = Files.readAllBytes(path);
        String content = new String(bytes, StandardCharsets.UTF_8);
        System.out.println(content);
        String str = "张三";
        Files.write(path,str.getBytes(StandardCharsets.UTF_8));
        Files.write(path,"是个2B".getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND);


    }
}
